<?php

namespace App\Extensions\Pagination;

use Illuminate\Support\HtmlString;
use Illuminate\Pagination\BootstrapThreePresenter;

class BoosstrapPageUser extends BootstrapThreePresenter
{
    /**
     * Convert the URL window into Bootstrap HTML.
     *
     * @return \Illuminate\Support\HtmlString
     */
    public function render()
    {
        // dump($this->total());
        $page=$this->paginator->toArray();
        // dd($page);
        if ($this->hasPages()) {
            return new HtmlString(sprintf(
                '<div class="uc-page-box text-right">%s %s %s</div>',
                // $this->getPreviousButton(),
                '<span class="total">共'.$page['total'].'条数据</span>',
                $this->getLinks(),
                // $this->getNextButton()
                '<span>'.$page['current_page'].'/'.ceil($page['total']/$page['per_page']).'页</span>'
            ));
        }

        return '';
    }

    protected function getAvailablePageWrapper($url, $page, $rel = null)
    {
        return  '<a href="'.htmlentities($url).'#page">'.$page.'</a>';
    }
    /**
     * Get HTML wrapper for disabled text.
     *
     * @param  string  $text
     * @return string
     */
    protected function getDisabledTextWrapper($text)
    {
        return '<a href="#page" class="disabled">'.$text.'</a>';
    }

    /**
     * Get HTML wrapper for active text.
     *
     * @param  string  $text
     * @return string
     */
    protected function getActivePageWrapper($text)
    {
        return '<a href="#page" class="current">'.$text.'</a>';
    }
}